<?php

namespace app\model;

use think\facade\Db;
use think\Model;

class OrderAdminRemarkModel extends Model {

    protected $table ="order_admin_remark";

    protected $pk = 'id';


    /*
   * 获取total
   * */
    public function getTotal($where=[]){
        return Db::name($this->table)->where($where)->count();
    }


    /*
     * 获取list
     * */
    public function getList($where,$page = null,$limit = null,$orderField = null,$orderType = "ASC"){

        $obj =  Db::name($this->table)->where($where);

        if(!empty($field) ) {
            $obj = $obj->field($field);
        }

        if(!empty($page) && !empty($limit)){
            $obj = $obj->page($page, $limit);
        }

        if(!empty($orderField) && !empty($orderType)){
            $obj = $obj->order($orderField, $orderType);
        }

        $list = $obj->select();

        if($list){
            return $list->toArray();
        }
        return [];
    }




    /*
    * 保存数据
    * */
    public function addOne($data){
        return Db::name($this->table)->insertGetId($data);
    }



    /*
* 保存数据
* */
    public function updateOne($where,$data){
        return Db::name($this->table)->where($where)->update($data);
    }


}